<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>JavaScript学习-时间控制</title>
		<script type="text/javascript" >
			const_txt = '你好，这里是火星基地，wellcom to mars~!!!';
			var count=0;
			function TimeToShow() {
				
				if (count<const_txt.length){
					var show_txt=document.getElementById('time_show').innerHTML;
					show_txt=show_txt+const_txt[count];
					document.getElementById('time_show').innerHTML=show_txt;
					t=setTimeout('TimeToShow()',70);
					count+=1;
				}
			}

		</script>
	</head>
	<body>
		<div style="height: 180px;width: 420px;background-color: green;color:yellow">
			<p>
				指定一个字符串，定时逐个输出实现打字效果
			</p>
			<input type='button' value='开始' onclick="TimeToShow()" />
			<p id='time_show' style="color: white">
				&nbsp;
			</p>
		</div>

	</body>
</html>